package com.bw.hongye.building.controller;

import com.aliyun.common.utils.PageUtils;
import com.aliyun.common.utils.R;
import com.bw.hongye.building.entity.BuildingEntity;
import com.bw.hongye.building.service.BuildingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 
 *
 * @author tZhe
 * @email tZhe@hongye.com
 * @date 2021-07-16 16:52:05
 */
@RestController
@CrossOrigin
@RequestMapping("building/building")
public class BuildingController {
    @Autowired
    private BuildingService buildingService;



    @GetMapping
    public String a(){
        System.out.println("进来了");
        return "啦啦啦";
    }
    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = buildingService.queryPage(params);
        System.out.println(1);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{bulidingId}")
    public R info(@PathVariable("bulidingId") Long bulidingId){
		BuildingEntity building = buildingService.getById(bulidingId);

        return R.ok().put("building", building);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody BuildingEntity building){

		buildingService.save(building);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody BuildingEntity building){
		buildingService.updateById(building);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] bulidingIds){
		buildingService.removeByIds(Arrays.asList(bulidingIds));

        return R.ok();
    }
}
